var V=new Vue({
    el:'#main',
    data:()=>({
        listdata:[],
        page:1,
        sousuo:'',
        lang:"",
        title:1123,
        order: 1,
        pro_id:0
    }),
    methods:{
        changefn(lang){
            this.lang=lang
        },
        requestSearch(){
            this.getdata()
        },
        getdata(){
            $.ajax({
                url:'/admin/product/proaddnewjump?request=intro&pro_id='+$('#pro_id').val(),
                data: {
                    page: this.page,
                    limit: 10,
                    lang: this.lang
                },
                type:'post',
                success:(data)=>{                    
                    data = JSON.parse(data)
                    this.pro_id = data.pro_id
                    this.listdata=data.prodesc_cat
                }
            })
        },
        setPage(pageCurrent,pageize) {
            $(".pagination").bootstrapPaginator({
                //设置版本号
                bootstrapMajorVersion: 3,
                // 显示第几页
                currentPage: pageCurrent,
                // 总页数
                totalPages: pageize,
                //当单击操作按钮的时候, 执行该函数, 调用ajax渲染页面
                onPageClicked: (event, originalEvent, type, page)=>{
                    // 把当前点击的页码赋值给currentPage, 调用ajax,渲染页面
                    currentPage = page
                    this.page=page
                }
            })
        },
        sortfun($event){  //排序
            this.order = $(event.target).attr('data-order')
            this.listdata.sort(this.sortoneData);
        },
        sortoneData(a, b) {
            console.log(a,b)
            if (this.order == 1) {
                $(event.target).attr('data-order', 2)
                return b.update_at - a.update_at
            } else {
                $(event.target).attr('data-order', 1)
                return a.update_at - b.update_at
            }
        },
        requestDel(id,pro_id){
            $.ajax({
                url:'/admin/product/proAddNewJump_introDel',
                data: {
                    prodesc_cat_id:id,
                    pro_id:pro_id
                },
                type:'post',
                success:(data)=>{
                    data = JSON.parse(data)
                    if (data.status != 1) {
                        change_mes_type('.modal-body .alert',data.status)
                        $('.modal-body .alert').show()
                        $('.modal-body .alert p').html('*'+data.msg+'<br>')
                    } else {
                        change_mes_type('.alert',data.status)
                        $('.alert').show()
                        $('.alert p').html('*'+data.msg+'<br>')
                        this.getdata()
                    }
                }
            })
        }
    },
    mounted(){
        this.getdata()
        $('#prointro_editModal').on('hidden.bs.modal',(e) =>{
            console.log('123456789')
            $("#proTab li").click(function (e) {
                e.preventDefault()
                $(this).tab('show')
                window.location.href = $(this).children('a').attr('href')
            })
            this.getdata()
        });
    },
    watch:{
        lang:function(){
            this.getdata()
        }
    }
})